<template>
  <el-container
    style="padding: 10px;border: solid 1px; border-radius: 15px; background-color: #ffffff; width: 430px; display: flex; justify-content: center">
    <el-main style="display: flex;justify-content: center">
      <el-scrollbar
        style="border-radius: 15px;border: solid 1px ; z-index: 10001;width:400px; height: 500px">
        <el-menu ref="menuMoveTo" text-color="#000000" active-text-color="#ffffff" @open="changeTarget"
                 @close="changeTarget">
          <target-tree :ch="files" :page="this"></target-tree>
        </el-menu>
      </el-scrollbar>
    </el-main>
    <el-footer style="display: flex;justify-content: center">
      <div style="display: flex; align-items: center">
        <el-button type="primary" round @click="moveTo">确认移动</el-button>
        <span v-bind:value="targetFolder">到{{this.targetFolder}}</span>
      </div>
    </el-footer>
  </el-container>
</template>

<script>

  export default {
    name: "MoveWindow",
    props: {
      files: {},
      page: {},
      origin: ""
    },
    data() {
      return {
        targetFolder: ""
      }
    },
    methods: {
      changeTarget(key, keyPath) {
        this.targetFolder = "";
        for (const i in keyPath) {
          this.targetFolder += keyPath[i];
          this.targetFolder += '/';
        }
      },
      moveTo() {
        this.apis.moveFileOrFolder(this.origin, this.targetFolder, res => {
          this.page.updateFileTree();
          this.page.search();
          this.page.isMoving = false;
        })
      }
    }
  }
</script>

<style scoped>

  .el-main {
    width: 400px;
  }

  .el-footer {
    width: 400px;
  }

</style>
